﻿using System;
using System.Windows.Data;
using System.Collections.Generic;
using AccessControl.Contracts.Models;

namespace AccessControl.Wpf.Converters
{
	class IsEntryInListConverter : IMultiValueConverter
	{
		#region IMultiValueConverter Members

		public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (values[0] == null || values[1] == null)
				return false;

			IEntry entry = (IEntry)values[0];
			IList<IEntry> entries = (IList<IEntry>)values[1];

			foreach (IEntry val in entries)
				if (val.Id == entry.Id)
					return true;

			return false;
		}

		public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}
